// channels的仓库数据

import { getNewsChannels } from "../services/newsServices"

export default {
    namespaced: true,//开启命名空间
    state: {
        data: [],
        isLoading: false
    },
    mutations: {
        setIsLoading(state, payload) {
            state.isLoading = payload;
        },
        setData(state, payload) {
            state.data = payload
        }
    },
    actions: {
        async fetchDatas(context) {
            context.commit('setIsLoading', true)
            var channels = await getNewsChannels()
            context.commit('setData', channels)
            context.commit('setIsLoading', false)
        }
    }
} 